import 'package:application_with_bilibili/examples/main_05_expanded.dart';
import 'package:flutter/material.dart';

void main(List<String> args) {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '我的',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
            seedColor: const Color.fromARGB(255, 255, 2, 2)),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text(
            '一堆按钮',
            style: TextStyle(fontSize: 18),
          ),
        ),
        body: MyBody(),
      ),
    );
  }
}

class MyBody extends StatelessWidget {
  const MyBody({super.key});

  @override
  Widget build(BuildContext context) {
    return ButtonDemo();
  }
}

class ButtonDemo extends StatelessWidget {
  const ButtonDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        // 普通按钮
        ElevatedButton(
          onPressed: () {},
          child: const Text("世界毁灭"),
        ),
        // 纯文字按钮
        TextButton(
          onPressed: () {},
          child: const Text("取消毁灭"),
        ),
        // 边框按钮
        OutlinedButton(
          onPressed: () {},
          style: ButtonStyle(
            // 设置边框的宽度
            side: WidgetStatePropertyAll(BorderSide(
                width: 1.5, color: const Color.fromARGB(255, 209, 35, 35))),
          ),
          child: const Text("来一把任天堂"),
        ),
        // 图标按钮
        IconButton(
          onPressed: () {},
          icon: const Icon(Icons.gamepad),
        ),
        ColorBlock(
          height: 20,
          color: Colors.red,
        ),
        ColorBlock(
          height: 20,
          color: Colors.black,
        ),
        ColorBlock(
          height: 20,
          color: Colors.red,
        ),
        // 可以加上.icon定义按钮图标，其他类型的按钮也是同理
        ElevatedButton.icon(
          onPressed: () {
            print("时光的力量，被暗藏在了这里");
          },
          icon: const Icon(Icons.music_video),
          label: const Text("塞尔达传说——时之笛"),
          style: ButtonStyle(
            backgroundColor: WidgetStatePropertyAll(
              const Color.fromARGB(255, 226, 194, 14),
            ),
            foregroundColor: WidgetStatePropertyAll(
              const Color.fromARGB(255, 194, 71, 0),
            ),
          ),
        ),
        // 用SizedBox来设置按钮的大小，当然这里的width无法生效，因为在Column中
        SizedBox(
          height: 100,
          width: 80,
          child: ElevatedButton(
            onPressed: () {
              print("dududududu~");
            },
            child: const Text("演奏"),
          ),
        ),
        ElevatedButton(
          onPressed: () {},
          style: ButtonStyle(
            // 设置按钮的形状
            shape: WidgetStatePropertyAll(
              BeveledRectangleBorder(borderRadius: BorderRadius.circular(20)),
            ),
            backgroundColor: WidgetStatePropertyAll(
              const Color.fromARGB(255, 255, 0, 0),
            ),
            foregroundColor: WidgetStatePropertyAll(
              const Color.fromARGB(255, 255, 255, 255),
            ),
          ),
          child: const Text("结束"),
        ),
      ],
    );
  }
}
